#include <stdint.h>
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdio.h>
#include <pthread.h>
#include <poll.h>

#define DELAY_CMD_OPEN   _IOW('A',0,unsigned int)
#define DELAY_CMD_CLOSE   _IOW('A',1,unsigned int)
#define DELAY_CMD_2   _IOW('A',2,unsigned int)
#define DELAY_CMD_9   _IOW('A',9,unsigned int)

void* ioctl01(void *ptr) {
	int fd = open("/dev/t01", O_RDWR, O_NONBLOCK);
	if (fd < 0) {
		perror("open");
		printf("error open\n");
		return NULL;
	}
	printf("ioctl 2\n");
	ioctl(fd, DELAY_CMD_2, 100);
	sleep(4);
	printf("ioctl 9\n");
	ioctl(fd, DELAY_CMD_9, 100);
	close(fd);
	return NULL;
}

int main() {
	pthread_t thread;
	pthread_create(&thread, NULL, ioctl01, NULL);
	pthread_join(thread, NULL);
	printf("main exit\n");
	return EXIT_SUCCESS;
}

